package es.agroservicio.Agroservicio.controller;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import es.agroservicio.Agroservicio.repository.BillsDAO;
import es.agroservicio.Agroservicio.service.BillsManager;

@Controller
public class BillsController {

	@Autowired
	private BillsManager billsManager;
	@Autowired
	private BillsDAO billsDao;

	protected final Log logger = LogFactory.getLog(getClass());

	@RequestMapping(value = "/bills.html")
	public ModelAndView handleRequest(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

		String now = (new Date()).toString();
		logger.info("Returning hello view with " + now);

		Map<String, Object> myModel = new HashMap<String, Object>();
		myModel.put("now", now);
		
		List<String> names = new ArrayList<String>();
		names.add("\"Juan Javier\"");
		names.add("\"Antonio\"");
		names.add("\"Ana\"");

		myModel.put("clientsNames", names);

		return new ModelAndView("bills", "model", myModel);
	}

}
